import config from './http-config'
class HTTP {
    constructor() {
        this.baseUrl = config.api_baseUrl
    }
    request(params) {
        let url = this.baseUrl + params.url
        return new Promise((resolve, reject) => {
            wx.request({
                url: url,
                method: params.method,
                data: params.data,
                timeout: 5000,
                success: function(res) {
                    // params.success && params.success(res)
                    resolve(res.data)
                },
                fail: function(err) {
                    // params.fail && params.fail(err)
                    reject(err)
                }
            })
        })
       
    }
}
export default HTTP